package com.woniuxy.core.mapper;

import com.woniuxy.entity.UserEarnings;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

public interface RankingMapper {
    @Update("update user_earnings set earnings = #{earnings} where user_id = #{userId}")
    void updateRanking(@Param("userId") int userId, @Param("earnings") BigDecimal earnings);
    @Select("select earnings from user_earnings where user_id = #{userId}")
    BigDecimal selEarnings(int userId);
    @Insert("insert into user_earnings(user_id,username,earnings,create_time,update_time)" +
            "values (#{userEarnings.userId},#{userEarnings.username}," +
            "#{userEarnings.earnings},#{userEarnings.createTime},#{userEarnings.updateTime})")
    void addRanking(@Param("userEarnings") UserEarnings userEarnings);
}
